package com.wyp168.jvm001.gc;

/**
 * @ClassName SystemGCDemo001
 * @Description TODO
 * @Author wyp168
 * @Date 2022/9/1 23:00
 */
public class SystemGCDemo001 {
    private static SystemGCDemo001 reference;
    public static void main(String[] args) throws InterruptedException {
        new SystemGCDemo001();
//        reference = null;
        System.gc();
//        Thread.sleep(10000);
        //该方法强制执行被视为垃圾（没有任何对象引用的对象）对象的finalize()方法
//        System.runFinalization();
//        label:
//        for (int i = 0; i <10; i++) {
//            System.out.println(1);
//            if (i == 5 ) {
//                break ok;
//            }
//        }
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("当前对象重写了finalize()方法");
    }
}
